import { Component } from '@angular/core';
// import { Platform } from 'ionic-angular';

import { AboutPage } from '../about/about';
import { ContactPage } from '../contact/contact';
import { HomePage } from '../home/home';

import { LocalNotifications } from '@ionic-native/local-notifications'; // 通知
import { Vibration } from '@ionic-native/vibration'; // 震动
// import { NativeAudio } from '@ionic-native/native-audio'; // 声音

@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {

  tab1Root = HomePage;
  tab2Root = AboutPage;
  tab3Root = ContactPage;
  messages = 0;

  constructor(
    // private platform: Platform,
    private notis: LocalNotifications,
    private vibration: Vibration,
    // private nativeAudio: NativeAudio
  ) {
    // this.nativeAudio.preloadSimple('message-1', '../../assets/video/7142.wav').then(() => { }, () => { }) // 加载音频
    setInterval(() => {
      // '1' === window.sessionStorage.getItem('backstage') && this.scheduleNotis() // 本地推送
    }, 10000)
  }

  scheduleNotis() {
    let date = new Date()
    this.notis.schedule({
      id: date.getTime(),
      text: `本地推送测试 ${date.toLocaleTimeString()}`,
      // sound: null // 不传递sound:调用默认系统提示音
    })

    this.vibration.vibrate(500); // 震动
    // this.nativeAudio.play('message-1').then(() => { }, () => { }) // 提示音
  }

}
